package com.briup.dao.impl;

import java.util.ArrayList;
import java.util.List;

import org.apache.ibatis.session.SqlSession;

import com.briup.bean.Report;
import com.briup.dao.IReportDao;
import com.briup.util.DBTool;

public class IReportDaoImpl implements IReportDao{
	@Override
	public void addReport(Report report) {
		SqlSession session = DBTool.getSession();
		session.insert("s_report.insertOne", report);
		session.commit();
		session.close();
	}
	

	@Override
	public void updateOneReport(Report report) {
		SqlSession session = DBTool.getSession();
		session.update("s_report.updateOne", report);
		session.commit();
		session.close();
		
	}

	@Override
	public void deleteReport(Long reportId) {
		SqlSession session = DBTool.getSession();
		session.delete("s_report.deleteOne", reportId);
		session.commit();
		session.close();
	}

	@Override
	public List<Report> listAllReport() {
		List<Report> list = new ArrayList<>();
		SqlSession session = DBTool.getSession();
		list = session.selectList("s_report.selectAll");
		session.commit();
		session.close();
		return list;
	}
	
	public static void main(String[] args) {
		IReportDao dao = new IReportDaoImpl();
		List<Report> list = dao.listAllReport();
		System.out.println(list);
	}

}
